package zgs;

import java.lang.reflect.Method;

/*
* 反射机制调用有参方法
* */
public class ReflectDemo5 {

    public static void main(String[] args) throws Exception {

        Person p = new Person();
        p.say("hello",5);

        System.out.println("-----------------");


        Class cls = Class.forName("zgs.Person");
        Object obj = cls.newInstance();
        Method m = cls.getMethod("say",String.class,int.class);
        m.invoke(obj,"hello",5);

        System.out.println("-----------------------");

        Method m1 = cls.getMethod("say",String.class);
        m1.invoke(obj,"hello");





    }
}
